

$(document).ready(function () {

function getlocation() {

    if (isNull(sessionStorage.getItem('autoLocation'))) {

        try {
            var map, geolocation;
            //加载地图，调用浏览器定位服务
            map = new AMap.Map('container', {
                resizeEnable: true
            });
            map.plugin('AMap.Geolocation', function() {
                geolocation = new AMap.Geolocation({
                    enableHighAccuracy: true,//是否使用高精度定位，默认:true
                    timeout: 10000,          //超过10秒后停止定位，默认：无穷大
                });
                map.addControl(geolocation);
                geolocation.getCurrentPosition();

                AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
                AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息

            });


            //解析定位结果
            function onComplete(data) {
                // console.log(data)
                let cityName=data.addressComponent.city;

                let geocoder = new AMap.Geocoder({
                });
                //地理编码,返回地理编码结果
                geocoder.getLocation(cityName, function(status, result) {
                    if (status === 'complete' && result.info === 'OK') {

                        let cityAdcode=result.geocodes[0].adcode;
                        sessionStorage.setItem('autoLocation', cityName);
                        sessionStorage.setItem('autoLocationCode', cityAdcode);

                        $('#locationCity,#cityName,#cityName_dajindai,#chooseCity').html(cityName)


                    }
                });


            }
            // //解析定位错误信息
            // function onError() {
            //
            //     let str = '自动定位失败，点击手动选择';
            //
            //     $("#chooseCity").text(str);
            //
            // }
            function onError() {

            }


            var citysearch = new AMap.CitySearch();
            //自动获取用户IP，返回当前城市
            citysearch.getLocalCity(function (status, result) {
                if (status === 'complete' && result.info === 'OK') {
                    if (result && result.city && result.bounds) {
                        let GetUserLocation = result.city,
                            GetUserLocationcode = result.adcode;

                        if(isNull(sessionStorage.getItem('autoLocation'))){

                            sessionStorage.setItem('autoLocation', GetUserLocation);
                            sessionStorage.setItem('autoLocationCode', GetUserLocationcode);

                            $('#locationCity,#cityName,#cityName_dajindai,#chooseCity').html(GetUserLocation)


                        }
                    }
                } else {

                    $('#locationCity,#cityName').html('定位失效，请点击手动选择')
                }
            })
        }

        catch (e) {
            console.log('引用定位失败')
        }

    }else {

        if(isNull(sessionStorage.getItem('userChooseLocation'))){

            $('#locationCity,#cityName,#cityName_dajindai,#chooseCity').html(sessionStorage.getItem('autoLocation'))

        }else {
            $('#locationCity,#cityName').html(sessionStorage.getItem('userChooseLocation'))

        }


        if(isNull(sessionStorage.getItem('djdCityName'))){

            $('#cityName_dajindai,#chooseCity').html(sessionStorage.getItem('autoLocation'))

        }else{
            $('#chooseCity').html(sessionStorage.getItem('djdCityName'));


        }

    }
}

 getlocation();


const citylist=[
    {
        "code": "110000",
        "name": "北京市",
        "pinyin": "beijingshi"
    },
    {
        "code": "120000",
        "name": "天津市",
        "pinyin": "tianjinshi"
    },
    {
        "code": "130100",
        "name": "石家庄市",
        "pinyin": "shijiazhuangshi"
    },
    {
        "code": "130200",
        "name": "唐山市",
        "pinyin": "tangshanshi"
    },
    {
        "code": "130300",
        "name": "秦皇岛市",
        "pinyin": "qinhuangdaoshi"
    },
    {
        "code": "130400",
        "name": "邯郸市",
        "pinyin": "handanshi"
    },
    {
        "code": "130500",
        "name": "邢台市",
        "pinyin": "xingtaishi"
    },
    {
        "code": "130600",
        "name": "保定市",
        "pinyin": "baodingshi"
    },
    {
        "code": "130700",
        "name": "张家口市",
        "pinyin": "zhangjiakoushi"
    },
    {
        "code": "130800",
        "name": "承德市",
        "pinyin": "chengdeshi"
    },
    {
        "code": "130900",
        "name": "沧州市",
        "pinyin": "cangzhoushi"
    },
    {
        "code": "131000",
        "name": "廊坊市",
        "pinyin": "langfangshi"
    },
    {
        "code": "131100",
        "name": "衡水市",
        "pinyin": "hengshuishi"
    },
    {
        "code": "140100",
        "name": "太原市",
        "pinyin": "taiyuanshi"
    },
    {
        "code": "140200",
        "name": "大同市",
        "pinyin": "datongshi"
    },
    {
        "code": "140300",
        "name": "阳泉市",
        "pinyin": "yangquanshi"
    },
    {
        "code": "140400",
        "name": "长治市",
        "pinyin": "changzhishi"
    },
    {
        "code": "140500",
        "name": "晋城市",
        "pinyin": "jinchengshi"
    },
    {
        "code": "140600",
        "name": "朔州市",
        "pinyin": "shuozhoushi"
    },
    {
        "code": "140700",
        "name": "晋中市",
        "pinyin": "jinzhongshi"
    },
    {
        "code": "140800",
        "name": "运城市",
        "pinyin": "yunchengshi"
    },
    {
        "code": "140900",
        "name": "忻州市",
        "pinyin": "xinzhoushi"
    },
    {
        "code": "141000",
        "name": "临汾市",
        "pinyin": "linfenshi"
    },
    {
        "code": "141100",
        "name": "吕梁市",
        "pinyin": "lvliangshi"
    },
    {
        "code": "150000",
        "name": "内蒙古自治区",
        "pinyin": "neimengguzizhiqu"
    },
    {
        "code": "150100",
        "name": "呼和浩特市",
        "pinyin": "huhehaoteshi"
    },
    {
        "code": "150200",
        "name": "包头市",
        "pinyin": "baotoushi"
    },
    {
        "code": "150300",
        "name": "乌海市",
        "pinyin": "wuhaishi"
    },
    {
        "code": "150400",
        "name": "赤峰市",
        "pinyin": "chifengshi"
    },
    {
        "code": "150500",
        "name": "通辽市",
        "pinyin": "tongliaoshi"
    },
    {
        "code": "150600",
        "name": "鄂尔多斯市",
        "pinyin": "eerduosi"
    },
    {
        "code": "150700",
        "name": "呼伦贝尔市",
        "pinyin": "hulunbeidongshi"
    },
    {
        "code": "150800",
        "name": "巴彦淖尔市",
        "pinyin": "bayannaodongshi"
    },
    {
        "code": "150900",
        "name": "乌兰察布市",
        "pinyin": "wulanchabushi"
    },
    {
        "code": "152200",
        "name": "兴安盟",
        "pinyin": "xinganmeng"
    },
    {
        "code": "152500",
        "name": "锡林郭勒盟",
        "pinyin": "xilinguolemeng"
    },
    {
        "code": "152900",
        "name": "阿拉善盟",
        "pinyin": "alashanmeng"
    },
    {
        "code": "210100",
        "name": "沈阳市",
        "pinyin": "shenyangshi"
    },
    {
        "code": "210200",
        "name": "大连市",
        "pinyin": "dalianshi"
    },
    {
        "code": "210300",
        "name": "鞍山市",
        "pinyin": "anshanshi"
    },
    {
        "code": "210400",
        "name": "抚顺市",
        "pinyin": "fushunshi"
    },
    {
        "code": "210500",
        "name": "本溪市",
        "pinyin": "benxishi"
    },
    {
        "code": "210600",
        "name": "丹东市",
        "pinyin": "dandongshi"
    },
    {
        "code": "210700",
        "name": "锦州市",
        "pinyin": "jinzhoushi"
    },
    {
        "code": "210800",
        "name": "营口市",
        "pinyin": "yingkoushi"
    },
    {
        "code": "210900",
        "name": "阜新市",
        "pinyin": "fuxinshi"
    },
    {
        "code": "211000",
        "name": "辽阳市",
        "pinyin": "liaoyangshi"
    },
    {
        "code": "211100",
        "name": "盘锦市",
        "pinyin": "panjinshi"
    },
    {
        "code": "211200",
        "name": "铁岭市",
        "pinyin": "tielingshi"
    },
    {
        "code": "211300",
        "name": "朝阳市",
        "pinyin": "chaoyangshi"
    },
    {
        "code": "211400",
        "name": "葫芦岛市",
        "pinyin": "huludaoshi"
    },
    {
        "code": "220100",
        "name": "长春市",
        "pinyin": "changchunshi"
    },
    {
        "code": "220200",
        "name": "吉林市",
        "pinyin": "jilinshi"
    },
    {
        "code": "220300",
        "name": "四平市",
        "pinyin": "sipingshi"
    },
    {
        "code": "220400",
        "name": "辽源市",
        "pinyin": "liaoyuanshi"
    },
    {
        "code": "220500",
        "name": "通化市",
        "pinyin": "tonghuashi"
    },
    {
        "code": "220600",
        "name": "白山市",
        "pinyin": "baishanshi"
    },
    {
        "code": "220700",
        "name": "松原市",
        "pinyin": "songyuanshi"
    },
    {
        "code": "220800",
        "name": "白城市",
        "pinyin": "baichengshi"
    },
    {
        "code": "222400",
        "name": "延边朝鲜族自治州",
        "pinyin": "yanbianchaoxianzuzizhizhou"
    },
    {
        "code": "230100",
        "name": "哈尔滨市",
        "pinyin": "hadongbinshi"
    },
    {
        "code": "230200",
        "name": "齐齐哈尔市",
        "pinyin": "qiqihadongshi"
    },
    {
        "code": "230300",
        "name": "鸡西市",
        "pinyin": "jixishi"
    },
    {
        "code": "230400",
        "name": "鹤岗市",
        "pinyin": "hegangshi"
    },
    {
        "code": "230500",
        "name": "双鸭山市",
        "pinyin": "shuangyashanshi"
    },
    {
        "code": "230600",
        "name": "大庆市",
        "pinyin": "daqingshi"
    },
    {
        "code": "230700",
        "name": "伊春市",
        "pinyin": "yichunshi"
    },
    {
        "code": "230800",
        "name": "佳木斯市",
        "pinyin": "jiamusishi"
    },
    {
        "code": "230900",
        "name": "七台河市",
        "pinyin": "qitaiheshi"
    },
    {
        "code": "231000",
        "name": "牡丹江市",
        "pinyin": "mudanjiangshi"
    },
    {
        "code": "231100",
        "name": "黑河市",
        "pinyin": "heiheshi"
    },
    {
        "code": "231200",
        "name": "绥化市",
        "pinyin": "suihuashi"
    },
    {
        "code": "232700",
        "name": "大兴安岭地区",
        "pinyin": "daxinganlingdiqu"
    },
    {
        "code": "310000",
        "name": "上海市",
        "pinyin": "shanghaishi"
    },
    {
        "code": "320100",
        "name": "南京市",
        "pinyin": "nanjingshi"
    },
    {
        "code": "320200",
        "name": "无锡市",
        "pinyin": "wuxishi"
    },
    {
        "code": "320300",
        "name": "徐州市",
        "pinyin": "xuzhoushi"
    },
    {
        "code": "320400",
        "name": "常州市",
        "pinyin": "changzhoushi"
    },
    {
        "code": "320500",
        "name": "苏州市",
        "pinyin": "suzhoushi"
    },
    {
        "code": "320600",
        "name": "南通市",
        "pinyin": "nantongshi"
    },
    {
        "code": "320700",
        "name": "连云港市",
        "pinyin": "lianyungangshi"
    },
    {
        "code": "320800",
        "name": "淮安市",
        "pinyin": "huaianshi"
    },
    {
        "code": "320900",
        "name": "盐城市",
        "pinyin": "yanchengshi"
    },
    {
        "code": "321000",
        "name": "扬州市",
        "pinyin": "yangzhoushi"
    },
    {
        "code": "321100",
        "name": "镇江市",
        "pinyin": "zhenjiangshi"
    },
    {
        "code": "321200",
        "name": "泰州市",
        "pinyin": "taizhoushi"
    },
    {
        "code": "321300",
        "name": "宿迁市",
        "pinyin": "suqianshi"
    },
    {
        "code": "330100",
        "name": "杭州市",
        "pinyin": "hangzhoushi"
    },
    {
        "code": "330200",
        "name": "宁波市",
        "pinyin": "ningboshi"
    },
    {
        "code": "330300",
        "name": "温州市",
        "pinyin": "wenzhoushi"
    },
    {
        "code": "330400",
        "name": "嘉兴市",
        "pinyin": "jiaxingshi"
    },
    {
        "code": "330500",
        "name": "湖州市",
        "pinyin": "huzhoushi"
    },
    {
        "code": "330600",
        "name": "绍兴市",
        "pinyin": "shaoxingshi"
    },
    {
        "code": "330700",
        "name": "金华市",
        "pinyin": "jinhuashi"
    },
    {
        "code": "330800",
        "name": "衢州市",
        "pinyin": "quzhoushi"
    },
    {
        "code": "330900",
        "name": "舟山市",
        "pinyin": "zhoushanshi"
    },
    {
        "code": "331000",
        "name": "台州市",
        "pinyin": "taizhoushi"
    },
    {
        "code": "331100",
        "name": "丽水市",
        "pinyin": "lishuishi"
    },
    {
        "code": "340100",
        "name": "合肥市",
        "pinyin": "hefeishi"
    },
    {
        "code": "340200",
        "name": "芜湖市",
        "pinyin": "wuhushi"
    },
    {
        "code": "340300",
        "name": "蚌埠市",
        "pinyin": "bangbushi"
    },
    {
        "code": "340400",
        "name": "淮南市",
        "pinyin": "huainanshi"
    },
    {
        "code": "340500",
        "name": "马鞍山市",
        "pinyin": "maanshanshi"
    },
    {
        "code": "340600",
        "name": "淮北市",
        "pinyin": "huaibeishi"
    },
    {
        "code": "340700",
        "name": "铜陵市",
        "pinyin": "tonglingshi"
    },
    {
        "code": "340800",
        "name": "安庆市",
        "pinyin": "anqingshi"
    },
    {
        "code": "341000",
        "name": "黄山市",
        "pinyin": "huangshanshi"
    },
    {
        "code": "341100",
        "name": "滁州市",
        "pinyin": "chuzhoushi"
    },
    {
        "code": "341200",
        "name": "阜阳市",
        "pinyin": "fuyangshi"
    },
    {
        "code": "341300",
        "name": "宿州市",
        "pinyin": "suzhoushi"
    },
    {
        "code": "341500",
        "name": "六安市",
        "pinyin": "liuanshi"
    },
    {
        "code": "341600",
        "name": "亳州市",
        "pinyin": "bozhoushi"
    },
    {
        "code": "341700",
        "name": "池州市",
        "pinyin": "chizhoushi"
    },
    {
        "code": "341800",
        "name": "宣城市",
        "pinyin": "xuanchengshi"
    },
    {
        "code": "350100",
        "name": "福州市",
        "pinyin": "fuzhoushi"
    },
    {
        "code": "350200",
        "name": "厦门市",
        "pinyin": "xiamenshi"
    },
    {
        "code": "350300",
        "name": "莆田市",
        "pinyin": "putianshi"
    },
    {
        "code": "350400",
        "name": "三明市",
        "pinyin": "sanmingshi"
    },
    {
        "code": "350500",
        "name": "泉州市",
        "pinyin": "quanzhoushi"
    },
    {
        "code": "350600",
        "name": "漳州市",
        "pinyin": "zhangzhoushi"
    },
    {
        "code": "350700",
        "name": "南平市",
        "pinyin": "nanpingshi"
    },
    {
        "code": "350800",
        "name": "龙岩市",
        "pinyin": "longyanshi"
    },
    {
        "code": "350900",
        "name": "宁德市",
        "pinyin": "ningdeshi"
    },
    {
        "code": "360100",
        "name": "南昌市",
        "pinyin": "nanchangshi"
    },
    {
        "code": "360200",
        "name": "景德镇市",
        "pinyin": "jingdezhenshi"
    },
    {
        "code": "360300",
        "name": "萍乡市",
        "pinyin": "pingxiangshi"
    },
    {
        "code": "360400",
        "name": "九江市",
        "pinyin": "jiujiangshi"
    },
    {
        "code": "360500",
        "name": "新余市",
        "pinyin": "xinyushi"
    },
    {
        "code": "360600",
        "name": "鹰潭市",
        "pinyin": "yingtanshi"
    },
    {
        "code": "360700",
        "name": "赣州市",
        "pinyin": "ganzhoushi"
    },
    {
        "code": "360800",
        "name": "吉安市",
        "pinyin": "jianshi"
    },
    {
        "code": "360900",
        "name": "宜春市",
        "pinyin": "yichunshi"
    },
    {
        "code": "361000",
        "name": "抚州市",
        "pinyin": "fuzhoushi"
    },
    {
        "code": "361100",
        "name": "上饶市",
        "pinyin": "shangraoshi"
    },
    {
        "code": "370100",
        "name": "济南市",
        "pinyin": "jinanshi"
    },
    {
        "code": "370200",
        "name": "青岛市",
        "pinyin": "qingdaoshi"
    },
    {
        "code": "370300",
        "name": "淄博市",
        "pinyin": "ziboshi"
    },
    {
        "code": "370400",
        "name": "枣庄市",
        "pinyin": "zaozhuangshi"
    },
    {
        "code": "370500",
        "name": "东营市",
        "pinyin": "dongyingshi"
    },
    {
        "code": "370600",
        "name": "烟台市",
        "pinyin": "yantaishi"
    },
    {
        "code": "370700",
        "name": "潍坊市",
        "pinyin": "weifangshi"
    },
    {
        "code": "370800",
        "name": "济宁市",
        "pinyin": "jiningshi"
    },
    {
        "code": "370900",
        "name": "泰安市",
        "pinyin": "taianshi"
    },
    {
        "code": "371000",
        "name": "威海市",
        "pinyin": "weihaishi"
    },
    {
        "code": "371100",
        "name": "日照市",
        "pinyin": "rizhaoshi"
    },
    {
        "code": "371200",
        "name": "莱芜市",
        "pinyin": "laiwushi"
    },
    {
        "code": "371300",
        "name": "临沂市",
        "pinyin": "linyishi"
    },
    {
        "code": "371400",
        "name": "德州市",
        "pinyin": "dezhoushi"
    },
    {
        "code": "371500",
        "name": "聊城市",
        "pinyin": "liaochengshi"
    },
    {
        "code": "371600",
        "name": "滨州市",
        "pinyin": "binzhoushi"
    },
    {
        "code": "371700",
        "name": "菏泽市",
        "pinyin": "hezeshi"
    },
    {
        "code": "410100",
        "name": "郑州市",
        "pinyin": "zhengzhoushi"
    },
    {
        "code": "410200",
        "name": "开封市",
        "pinyin": "kaifengshi"
    },
    {
        "code": "410300",
        "name": "洛阳市",
        "pinyin": "luoyangshi"
    },
    {
        "code": "410400",
        "name": "平顶山市",
        "pinyin": "pingdingshanshi"
    },
    {
        "code": "410500",
        "name": "安阳市",
        "pinyin": "anyangshi"
    },
    {
        "code": "410600",
        "name": "鹤壁市",
        "pinyin": "hebishi"
    },
    {
        "code": "410700",
        "name": "新乡市",
        "pinyin": "xinxiangshi"
    },
    {
        "code": "410800",
        "name": "焦作市",
        "pinyin": "jiaozuoshi"
    },
    {
        "code": "410900",
        "name": "濮阳市",
        "pinyin": "puyangshi"
    },
    {
        "code": "411000",
        "name": "许昌市",
        "pinyin": "xuchangshi"
    },
    {
        "code": "411100",
        "name": "漯河市",
        "pinyin": "luoheshi"
    },
    {
        "code": "411200",
        "name": "三门峡市",
        "pinyin": "sanmenxiashi"
    },
    {
        "code": "411300",
        "name": "南阳市",
        "pinyin": "nanyangshi"
    },
    {
        "code": "411400",
        "name": "商丘市",
        "pinyin": "shangqiushi"
    },
    {
        "code": "411500",
        "name": "信阳市",
        "pinyin": "xinyangshi"
    },
    {
        "code": "411600",
        "name": "周口市",
        "pinyin": "zhoukoushi"
    },
    {
        "code": "411700",
        "name": "驻马店市",
        "pinyin": "zhumadianshi"
    },
    {
        "code": "420100",
        "name": "武汉市",
        "pinyin": "wuhanshi"
    },
    {
        "code": "420200",
        "name": "黄石市",
        "pinyin": "huangshishi"
    },
    {
        "code": "420300",
        "name": "十堰市",
        "pinyin": "shiyanshi"
    },
    {
        "code": "420500",
        "name": "宜昌市",
        "pinyin": "yichangshi"
    },
    {
        "code": "420600",
        "name": "襄阳市",
        "pinyin": "xiangyangshi"
    },
    {
        "code": "420700",
        "name": "鄂州市",
        "pinyin": "erzhoushi"
    },
    {
        "code": "420800",
        "name": "荆门市",
        "pinyin": "jingmenshi"
    },
    {
        "code": "420900",
        "name": "孝感市",
        "pinyin": "xiaoganshi"
    },
    {
        "code": "421000",
        "name": "荆州市",
        "pinyin": "jingzhoushi"
    },
    {
        "code": "421100",
        "name": "黄冈市",
        "pinyin": "huanggangshi"
    },
    {
        "code": "421200",
        "name": "咸宁市",
        "pinyin": "xianningshi"
    },
    {
        "code": "421300",
        "name": "随州市",
        "pinyin": "suizhoushi"
    },
    {
        "code": "422800",
        "name": "恩施土家族苗族自治州",
        "pinyin": "enshitujiazumiaozuzizhizhou"
    },
    {
        "code": "430100",
        "name": "长沙市",
        "pinyin": "changshashi"
    },
    {
        "code": "430200",
        "name": "株洲市",
        "pinyin": "zhuzhoushi"
    },
    {
        "code": "430300",
        "name": "湘潭市",
        "pinyin": "xiangtanshi"
    },
    {
        "code": "430400",
        "name": "衡阳市",
        "pinyin": "hengyangshi"
    },
    {
        "code": "430500",
        "name": "邵阳市",
        "pinyin": "shaoyangshi"
    },
    {
        "code": "430600",
        "name": "岳阳市",
        "pinyin": "yueyangshi"
    },
    {
        "code": "430700",
        "name": "常德市",
        "pinyin": "changdeshi"
    },
    {
        "code": "430800",
        "name": "张家界市",
        "pinyin": "zhangjiajieshi"
    },
    {
        "code": "430900",
        "name": "益阳市",
        "pinyin": "yiyangshi"
    },
    {
        "code": "431000",
        "name": "郴州市",
        "pinyin": "chenzhoushi"
    },
    {
        "code": "431100",
        "name": "永州市",
        "pinyin": "yongzhoushi"
    },
    {
        "code": "431200",
        "name": "怀化市",
        "pinyin": "huaihuashi"
    },
    {
        "code": "431300",
        "name": "娄底市",
        "pinyin": "loudishi"
    },
    {
        "code": "433100",
        "name": "湘西土家族苗族自治州",
        "pinyin": "xiangxitujiazumiaozuzizhizhou"
    },
    {
        "code": "440100",
        "name": "广州市",
        "pinyin": "guangzhoushi"
    },
    {
        "code": "440200",
        "name": "韶关市",
        "pinyin": "shaoguanshi"
    },
    {
        "code": "440300",
        "name": "深圳市",
        "pinyin": "shenzhenshi"
    },
    {
        "code": "440400",
        "name": "珠海市",
        "pinyin": "zhuhaishi"
    },
    {
        "code": "440500",
        "name": "汕头市",
        "pinyin": "shantoushi"
    },
    {
        "code": "440600",
        "name": "佛山市",
        "pinyin": "foshanshi"
    },
    {
        "code": "440700",
        "name": "江门市",
        "pinyin": "jiangmenshi"
    },
    {
        "code": "440800",
        "name": "湛江市",
        "pinyin": "zhanjiangshi"
    },
    {
        "code": "440900",
        "name": "茂名市",
        "pinyin": "maomingshi"
    },
    {
        "code": "441200",
        "name": "肇庆市",
        "pinyin": "zhaoqingshi"
    },
    {
        "code": "441300",
        "name": "惠州市",
        "pinyin": "huizhoushi"
    },
    {
        "code": "441400",
        "name": "梅州市",
        "pinyin": "meizhoushi"
    },
    {
        "code": "441500",
        "name": "汕尾市",
        "pinyin": "shanweishi"
    },
    {
        "code": "441600",
        "name": "河源市",
        "pinyin": "heyuanshi"
    },
    {
        "code": "441700",
        "name": "阳江市",
        "pinyin": "yangjiangshi"
    },
    {
        "code": "441800",
        "name": "清远市",
        "pinyin": "qingyuanshi"
    },
    {
        "code": "441900",
        "name": "东莞市",
        "pinyin": "dongguanshi"
    },
    {
        "code": "442000",
        "name": "中山市",
        "pinyin": "zhongshanshi"
    },
    {
        "code": "445100",
        "name": "潮州市",
        "pinyin": "chaozhoushi"
    },
    {
        "code": "445200",
        "name": "揭阳市",
        "pinyin": "jieyangshi"
    },
    {
        "code": "445300",
        "name": "云浮市",
        "pinyin": "yunfushi"
    },
    {
        "code": "450000",
        "name": "广西壮族自治区",
        "pinyin": "guangxizhuangzuzizhiqu"
    },
    {
        "code": "450100",
        "name": "南宁市",
        "pinyin": "nanningshi"
    },
    {
        "code": "450200",
        "name": "柳州市",
        "pinyin": "liuzhoushi"
    },
    {
        "code": "450300",
        "name": "桂林市",
        "pinyin": "guilinshi"
    },
    {
        "code": "450400",
        "name": "梧州市",
        "pinyin": "wuzhoushi"
    },
    {
        "code": "450500",
        "name": "北海市",
        "pinyin": "beihaishi"
    },
    {
        "code": "450600",
        "name": "防城港市",
        "pinyin": "fangchenggangshi"
    },
    {
        "code": "450700",
        "name": "钦州市",
        "pinyin": "qinzhoushi"
    },
    {
        "code": "450800",
        "name": "贵港市",
        "pinyin": "guigangshi"
    },
    {
        "code": "450900",
        "name": "玉林市",
        "pinyin": "yulinshi"
    },
    {
        "code": "451000",
        "name": "百色市",
        "pinyin": "baiseshi"
    },
    {
        "code": "451100",
        "name": "贺州市",
        "pinyin": "hezhoushi"
    },
    {
        "code": "451200",
        "name": "河池市",
        "pinyin": "hechishi"
    },
    {
        "code": "451300",
        "name": "来宾市",
        "pinyin": "laibinshi"
    },
    {
        "code": "451400",
        "name": "崇左市",
        "pinyin": "chongzuoshi"
    },
    {
        "code": "460100",
        "name": "海口市",
        "pinyin": "haikoushi"
    },
    {
        "code": "460200",
        "name": "三亚市",
        "pinyin": "sanyashi"
    },
    {
        "code": "460300",
        "name": "三沙市",
        "pinyin": "sanshashi"
    },
    {
        "code": "460400",
        "name": "儋州市",
        "pinyin": "danzhoushi"
    },
    {
        "code": "500000",
        "name": "重庆市",
        "pinyin": "zhongqingshi"
    },
    {
        "code": "500200",
        "name": "县",
        "pinyin": "xian"
    },
    {
        "code": "510100",
        "name": "成都市",
        "pinyin": "chengdushi"
    },
    {
        "code": "510300",
        "name": "自贡市",
        "pinyin": "zigongshi"
    },
    {
        "code": "510400",
        "name": "攀枝花市",
        "pinyin": "panzhihuashi"
    },
    {
        "code": "510500",
        "name": "泸州市",
        "pinyin": "luzhoushi"
    },
    {
        "code": "510600",
        "name": "德阳市",
        "pinyin": "deyangshi"
    },
    {
        "code": "510700",
        "name": "绵阳市",
        "pinyin": "mianyangshi"
    },
    {
        "code": "510800",
        "name": "广元市",
        "pinyin": "guangyuanshi"
    },
    {
        "code": "510900",
        "name": "遂宁市",
        "pinyin": "suiningshi"
    },
    {
        "code": "511000",
        "name": "内江市",
        "pinyin": "neijiangshi"
    },
    {
        "code": "511100",
        "name": "乐山市",
        "pinyin": "leshanshi"
    },
    {
        "code": "511300",
        "name": "南充市",
        "pinyin": "nanchongshi"
    },
    {
        "code": "511400",
        "name": "眉山市",
        "pinyin": "meishanshi"
    },
    {
        "code": "511500",
        "name": "宜宾市",
        "pinyin": "yibinshi"
    },
    {
        "code": "511600",
        "name": "广安市",
        "pinyin": "guanganshi"
    },
    {
        "code": "511700",
        "name": "达州市",
        "pinyin": "dazhoushi"
    },
    {
        "code": "511800",
        "name": "雅安市",
        "pinyin": "yaanshi"
    },
    {
        "code": "511900",
        "name": "巴中市",
        "pinyin": "bazhongshi"
    },
    {
        "code": "512000",
        "name": "资阳市",
        "pinyin": "ziyangshi"
    },
    {
        "code": "513200",
        "name": "阿坝藏族羌族自治州",
        "pinyin": "abacangzuqiangzuzizhizhou"
    },
    {
        "code": "513300",
        "name": "甘孜藏族自治州",
        "pinyin": "ganzicangzuzizhizhou"
    },
    {
        "code": "513400",
        "name": "凉山彝族自治州",
        "pinyin": "liangshanyizuzizhizhou"
    },
    {
        "code": "520100",
        "name": "贵阳市",
        "pinyin": "guiyangshi"
    },
    {
        "code": "520200",
        "name": "六盘水市",
        "pinyin": "liupanshuishi"
    },
    {
        "code": "520300",
        "name": "遵义市",
        "pinyin": "zunyishi"
    },
    {
        "code": "520400",
        "name": "安顺市",
        "pinyin": "anshunshi"
    },
    {
        "code": "520500",
        "name": "毕节市",
        "pinyin": "bijieshi"
    },
    {
        "code": "520600",
        "name": "铜仁市",
        "pinyin": "tongrenshi"
    },
    {
        "code": "522300",
        "name": "黔西南布依族苗族自治州",
        "pinyin": "qianxinanbuyizumiaozuzizhizhou"
    },
    {
        "code": "522600",
        "name": "黔东南苗族侗族自治州",
        "pinyin": "qiandongnanmiaozudongzuzizhizhou"
    },
    {
        "code": "522700",
        "name": "黔南布依族苗族自治州",
        "pinyin": "qiannanbuyizumiaozuzizhizhou"
    },
    {
        "code": "530100",
        "name": "昆明市",
        "pinyin": "kunmingshi"
    },
    {
        "code": "530300",
        "name": "曲靖市",
        "pinyin": "qujingshi"
    },
    {
        "code": "530400",
        "name": "玉溪市",
        "pinyin": "yuxishi"
    },
    {
        "code": "530500",
        "name": "保山市",
        "pinyin": "baoshanshi"
    },
    {
        "code": "530600",
        "name": "昭通市",
        "pinyin": "zhaotongshi"
    },
    {
        "code": "530700",
        "name": "丽江市",
        "pinyin": "lijiangshi"
    },
    {
        "code": "530800",
        "name": "普洱市",
        "pinyin": "pudongshi"
    },
    {
        "code": "530900",
        "name": "临沧市",
        "pinyin": "lincangshi"
    },
    {
        "code": "532300",
        "name": "楚雄彝族自治州",
        "pinyin": "chuxiongyizuzizhizhou"
    },
    {
        "code": "532500",
        "name": "红河哈尼族彝族自治州",
        "pinyin": "honghehanizuyizuzizhizhou"
    },
    {
        "code": "532600",
        "name": "文山壮族苗族自治州",
        "pinyin": "wenshanzhuangzumiaozuzizhizhou"
    },
    {
        "code": "532800",
        "name": "西双版纳傣族自治州",
        "pinyin": "xishuangbannadaizuzizhizhou"
    },
    {
        "code": "532900",
        "name": "大理白族自治州",
        "pinyin": "dalibaizuzizhizhou"
    },
    {
        "code": "533100",
        "name": "德宏傣族景颇族自治州",
        "pinyin": "dehongdaizujingpozuzizhizhou"
    },
    {
        "code": "533300",
        "name": "怒江傈僳族自治州",
        "pinyin": "nujianglisuzuzizhizhou"
    },
    {
        "code": "533400",
        "name": "迪庆藏族自治州",
        "pinyin": "diqingcangzuzizhizhou"
    },
    {
        "code": "540000",
        "name": "西藏自治区",
        "pinyin": "xicangzizhiqu"
    },
    {
        "code": "540100",
        "name": "拉萨市",
        "pinyin": "lasashi"
    },
    {
        "code": "540200",
        "name": "日喀则市",
        "pinyin": "rikazeshi"
    },
    {
        "code": "540300",
        "name": "昌都市",
        "pinyin": "changdongshi"
    },
    {
        "code": "540400",
        "name": "林芝市",
        "pinyin": "linzhishi"
    },
    {
        "code": "540500",
        "name": "山南市",
        "pinyin": "shannanshi"
    },
    {
        "code": "542400",
        "name": "那曲地区",
        "pinyin": "naqudiqu"
    },
    {
        "code": "542500",
        "name": "阿里地区",
        "pinyin": "alidiqu"
    },
    {
        "code": "610100",
        "name": "西安市",
        "pinyin": "xianshi"
    },
    {
        "code": "610200",
        "name": "铜川市",
        "pinyin": "tongchuanshi"
    },
    {
        "code": "610300",
        "name": "宝鸡市",
        "pinyin": "baojishi"
    },
    {
        "code": "610400",
        "name": "咸阳市",
        "pinyin": "xianyangshi"
    },
    {
        "code": "610500",
        "name": "渭南市",
        "pinyin": "weinanshi"
    },
    {
        "code": "610600",
        "name": "延安市",
        "pinyin": "yananshi"
    },
    {
        "code": "610700",
        "name": "汉中市",
        "pinyin": "hanzhongshi"
    },
    {
        "code": "610800",
        "name": "榆林市",
        "pinyin": "yulinshi"
    },
    {
        "code": "610900",
        "name": "安康市",
        "pinyin": "ankangshi"
    },
    {
        "code": "611000",
        "name": "商洛市",
        "pinyin": "shangluoshi"
    },
    {
        "code": "620100",
        "name": "兰州市",
        "pinyin": "lanzhoushi"
    },
    {
        "code": "620200",
        "name": "嘉峪关市",
        "pinyin": "jiayuguanshi"
    },
    {
        "code": "620300",
        "name": "金昌市",
        "pinyin": "jinchangshi"
    },
    {
        "code": "620400",
        "name": "白银市",
        "pinyin": "baiyinshi"
    },
    {
        "code": "620500",
        "name": "天水市",
        "pinyin": "tianshuishi"
    },
    {
        "code": "620600",
        "name": "武威市",
        "pinyin": "wuweishi"
    },
    {
        "code": "620700",
        "name": "张掖市",
        "pinyin": "zhangyeshi"
    },
    {
        "code": "620800",
        "name": "平凉市",
        "pinyin": "pingliangshi"
    },
    {
        "code": "620900",
        "name": "酒泉市",
        "pinyin": "jiuquanshi"
    },
    {
        "code": "621000",
        "name": "庆阳市",
        "pinyin": "qingyangshi"
    },
    {
        "code": "621100",
        "name": "定西市",
        "pinyin": "dingxishi"
    },
    {
        "code": "621200",
        "name": "陇南市",
        "pinyin": "longnanshi"
    },
    {
        "code": "622900",
        "name": "临夏回族自治州",
        "pinyin": "linxiahuizuzizhizhou"
    },
    {
        "code": "623000",
        "name": "甘南藏族自治州",
        "pinyin": "gannancangzuzizhizhou"
    },
    {
        "code": "630100",
        "name": "西宁市",
        "pinyin": "xiningshi"
    },
    {
        "code": "630200",
        "name": "海东市",
        "pinyin": "haidongshi"
    },
    {
        "code": "632200",
        "name": "海北藏族自治州",
        "pinyin": "haibeicangzuzizhizhou"
    },
    {
        "code": "632300",
        "name": "黄南藏族自治州",
        "pinyin": "huangnancangzuzizhizhou"
    },
    {
        "code": "632500",
        "name": "海南藏族自治州",
        "pinyin": "hainancangzuzizhizhou"
    },
    {
        "code": "632600",
        "name": "果洛藏族自治州",
        "pinyin": "guoluocangzuzizhizhou"
    },
    {
        "code": "632700",
        "name": "玉树藏族自治州",
        "pinyin": "yushucangzuzizhizhou"
    },
    {
        "code": "632800",
        "name": "海西蒙古族藏族自治州",
        "pinyin": "haiximengguzucangzuzizhizhou"
    },
    {
        "code": "640000",
        "name": "宁夏回族自治区",
        "pinyin": "ningxiahuizuzizhiqu"
    },
    {
        "code": "640100",
        "name": "银川市",
        "pinyin": "yinchuanshi"
    },
    {
        "code": "640200",
        "name": "石嘴山市",
        "pinyin": "shizuishanshi"
    },
    {
        "code": "640300",
        "name": "吴忠市",
        "pinyin": "wuzhongshi"
    },
    {
        "code": "640400",
        "name": "固原市",
        "pinyin": "guyuanshi"
    },
    {
        "code": "640500",
        "name": "中卫市",
        "pinyin": "zhongweishi"
    },
    {
        "code": "650000",
        "name": "新疆维吾尔自治区",
        "pinyin": "xinjiangweiwudongzizhiqu"
    },
    {
        "code": "650100",
        "name": "乌鲁木齐市",
        "pinyin": "wulumuqishi"
    },
    {
        "code": "650200",
        "name": "克拉玛依市",
        "pinyin": "kelamayishi"
    },
    {
        "code": "650400",
        "name": "吐鲁番市",
        "pinyin": "tulufanshi"
    },
    {
        "code": "650500",
        "name": "哈密市",
        "pinyin": "hamishi"
    },
    {
        "code": "652300",
        "name": "昌吉回族自治州",
        "pinyin": "changjihuizuzizhizhou"
    },
    {
        "code": "652700",
        "name": "博尔塔拉蒙古自治州",
        "pinyin": "bodongtalamengguzizhizhou"
    },
    {
        "code": "652800",
        "name": "巴音郭楞蒙古自治州",
        "pinyin": "bayinguolengmengguzizhizhou"
    },
    {
        "code": "652900",
        "name": "阿克苏地区",
        "pinyin": "akesudiqu"
    },
    {
        "code": "653000",
        "name": "克孜勒苏柯尔克孜自治州",
        "pinyin": "kezilesukedongkezizizhizhou"
    },
    {
        "code": "653100",
        "name": "喀什地区",
        "pinyin": "kashidiqu"
    },
    {
        "code": "653200",
        "name": "和田地区",
        "pinyin": "hetiandiqu"
    },
    {
        "code": "654000",
        "name": "伊犁哈萨克自治州",
        "pinyin": "yilihasakezizhizhou"
    },
    {
        "code": "654200",
        "name": "塔城地区",
        "pinyin": "tachengdiqu"
    },
    {
        "code": "654300",
        "name": "阿勒泰地区",
        "pinyin": "aletaidiqu"
    },

];

const hotCity=[
    {
        "code": "110000",
        "name": "北京市",
        "pinyin": "beijingshi"
    },
    {
        "code": "310000",
        "name": "上海市",
        "pinyin": "shanghaishi"
    },
    {
        "code": "440100",
        "name": "广州市",
        "pinyin": "guangzhoushi"
    },
    {
        "code": "440300",
        "name": "深圳市",
        "pinyin": "shenzhenshi"
    },
    {
        "code": "320100",
        "name": "南京市",
        "pinyin": "nanjingshi"
    },
    {
        "code": "330100",
        "name": "杭州市",
        "pinyin": "hangzhoushi"
    },
    {
        "code": "420100",
        "name": "武汉市",
        "pinyin": "wuhanshi"
    },
    {
        "code": "500000",
        "name": "重庆市",
        "pinyin": "zhongqingshi"
    },
    {
        "code": "510100",
        "name": "成都市",
        "pinyin": "chengdushi"
    },
    {
        "code": "120000",
        "name": "天津市",
        "pinyin": "tianjinshi"
    },
    {
        "code": "430100",
        "name": "长沙市",
        "pinyin": "changshashi"
    },

    {
        "code": "320500",
        "name": "苏州市",
        "pinyin": "suzhoushi"
    }
];


let cityObj={};

let cityObjNotNull=[];
let cityObjNotNullFirstLetter=[];

let cityNameABCD='';
let cityNameEFGH='';
let cityNameJKLM='';

let cityNameNPQR='';
let cityNameSTWX='';
let cityNameYZ='';


for(let j=0;j<26;j++)
{
    let firstLetter=String.fromCharCode((65+j)).toLowerCase();

    cityObj[firstLetter]=[];

    for(let i= 0,lg=citylist.length;i<lg;i++) {

        if (firstLetter== citylist[i].pinyin.slice(0,1)) {

            cityObj[firstLetter].push(citylist[i]);

        }
    }
}


console.log(cityObj);


let listBox='',hotBox='';

for(let j=0;j<26;j++)
{
    let firstLetterLower=String.fromCharCode((65+j)).toLowerCase();

    let firstLetterUpper=String.fromCharCode((65+j)).toUpperCase();

    let firstLetterlength=cityObj[firstLetterLower].length;

    if(firstLetterlength>0){
        // console.log(firstLetterlength);
        cityObjNotNull.push(cityObj[firstLetterLower]);
        cityObjNotNullFirstLetter.push(firstLetterUpper)

    }


}

for(let j=0;j<4;j++){
  let span='<span class="nameP">'+cityObjNotNullFirstLetter[j]+'</span>'  ;
  let cityListInner='';

    for(let n=0,lg=cityObjNotNull[j].length;n<lg;n++){

        cityListInner +='<span data-name="'+cityObjNotNull[j][n].name+'" data-code="'+cityObjNotNull[j][n].code+'">'+cityObjNotNull[j][n].name+'</span>'

    }

    cityNameABCD +='<div class="firstLetter">' +
                       span +
        '             <div class="cityListInner">'+cityListInner+'</div>' +
        '         </div>'

}

$('.cityNameABCD').append(cityNameABCD);


for(let j=4;j<8;j++){
    let span='<span class="nameP">'+cityObjNotNullFirstLetter[j]+'</span>'  ;
    let cityListInner='';

    for(let n=0,lg=cityObjNotNull[j].length;n<lg;n++){

        cityListInner +='<span data-name="'+cityObjNotNull[j][n].name+'" data-code="'+cityObjNotNull[j][n].code+'">'+cityObjNotNull[j][n].name+'</span>'

    }

    cityNameEFGH +='<div class="firstLetter">' +
        span +
        '             <div class="cityListInner">'+cityListInner+'</div>' +
        '         </div>'

}

$('.cityNameEFGH').append(cityNameEFGH);


for(let j=8;j<12;j++){
    let span='<span class="nameP">'+cityObjNotNullFirstLetter[j]+'</span>'  ;
    let cityListInner='';

    for(let n=0,lg=cityObjNotNull[j].length;n<lg;n++){

        cityListInner +='<span data-name="'+cityObjNotNull[j][n].name+'" data-code="'+cityObjNotNull[j][n].code+'">'+cityObjNotNull[j][n].name+'</span>'

    }

    cityNameJKLM +='<div class="firstLetter">' +
        span +
        '             <div class="cityListInner">'+cityListInner+'</div>' +
        '         </div>'

}

$('.cityNameJKLM').append(cityNameJKLM);

for(let j=12;j<16;j++){
    let span='<span class="nameP">'+cityObjNotNullFirstLetter[j]+'</span>'  ;
    let cityListInner='';

    for(let n=0,lg=cityObjNotNull[j].length;n<lg;n++){

        cityListInner +='<span data-name="'+cityObjNotNull[j][n].name+'" data-code="'+cityObjNotNull[j][n].code+'">'+cityObjNotNull[j][n].name+'</span>'

    }

    cityNameNPQR +='<div class="firstLetter">' +
        span +
        '             <div class="cityListInner">'+cityListInner+'</div>' +
        '         </div>'

}

$('.cityNameNPQR').append(cityNameNPQR);

for(let j=16;j<20;j++){
    let span='<span class="nameP">'+cityObjNotNullFirstLetter[j]+'</span>'  ;
    let cityListInner='';

    for(let n=0,lg=cityObjNotNull[j].length;n<lg;n++){

        cityListInner +='<span data-name="'+cityObjNotNull[j][n].name+'" data-code="'+cityObjNotNull[j][n].code+'">'+cityObjNotNull[j][n].name+'</span>'

    }

    cityNameSTWX +='<div class="firstLetter">' +
        span +
        '             <div class="cityListInner">'+cityListInner+'</div>' +
        '         </div>'

}

$('.cityNameSTWX').append(cityNameSTWX);

for(let j=20;j<22;j++){
    let span='<span class="nameP">'+cityObjNotNullFirstLetter[j]+'</span>'  ;
    let cityListInner='';

    for(let n=0,lg=cityObjNotNull[j].length;n<lg;n++){

        cityListInner +='<span data-name="'+cityObjNotNull[j][n].name+'" data-code="'+cityObjNotNull[j][n].code+'">'+cityObjNotNull[j][n].name+'</span>'

    }

    cityNameYZ +='<div class="firstLetter">' +
        span +
        '             <div class="cityListInner">'+cityListInner+'</div>' +
        '         </div>'

}

$('.cityNameYZ').append(cityNameYZ);


//热门城市

for(let j=0,hj=hotCity.length;j<hj;j++){
    hotBox+='<span data-code="'+hotCity[j].code+'" data-name='+hotCity[j].name+'>'+hotCity[j].name+'</span>';
}

$('#hotCity').html(hotBox);
$('#hotCity_dajindai').html(hotBox);

$('.nav').find('span').click(function () {

    $('.nav').find('span').removeClass('span_bottom');
    $(this).addClass('span_bottom');
    $('.cityList').children().hide();

    var className=$(this).data('classname');

    switch (className) {
        case 'hotCity':
           $('.hotCity').show();
        break;
        case 'cityNameABCD':
            $('.cityNameABCD').show();
            break;
        case 'cityNameEFGH':
            $('.cityNameEFGH').show();
            break;
        case 'cityNameJKLM':
            $('.cityNameJKLM').show();
            break;
        case 'cityNameNPQR':
            $('.cityNameNPQR').show();
            break;
        case 'cityNameSTWX':
            $('.cityNameSTWX').show();
            break;
        case 'cityNameYZ':
            $('.cityNameYZ').show();
            break;
    }

});

$('#close').click(function () {
    $('.chooseCityBox').hide();
});
$('#close_dajinda').click(function () {
    $('.chooseCityBox_dajindai').hide();

    $('#chooseCity').removeClass('clickInput');
});

$('#locationCity').click(function () {
    $('.chooseCityBox').show();
    sessionStorage.setItem('indexChooseCity','jdj');
});

$('.hotCity,.cityNameABCD,.cityNameEFGH,.cityNameJKLM,.cityNameNPQR,.cityNameSTWX,.cityNameYZ').on('click','span',function () {

    var this_ = $(this);

    var indexChooseCity=sessionStorage.getItem('indexChooseCity');

    if (indexChooseCity==='jdj') {

    sessionStorage.setItem('userChooseLocation', this_.data('name'));
    sessionStorage.setItem('userChooseLocationCode', this_.data('code'));

    $('#locationCity,#cityName,#locationCity_dajindai,#cityName_dajindai').html(this_.data('name'));

}else {
        sessionStorage.setItem('djdCityName', this_.data('name'));
        sessionStorage.setItem('djdCityCode', this_.data('code'));

        console.log(this_.data('name'));


        $('.dajindaiCityInput').val(this_.data('name')).data('value',this_.data('name'))
    }

    $('.chooseCityBox').hide();




});



});




